package myJs.user.workflow.featureSelection.dataMatrix

import com.softwaremill.quicklens._
import myJs.myPkg.reactHookForm.UseFormRT
import shared.Pojo.{DataMatrixData, FsPreprocessData}
import shared.pojo.WorkflowMission.{ExtraData, FsData}

import japgolly.scalajs.react.vdom.all._
import japgolly.scalajs.react._
import japgolly.scalajs.react.React.Fragment
import japgolly.scalajs.react.util.EffectCatsEffect._
import myJs.myPkg.Hooks._
import cats.effect._
import myJs.Implicits._

/** Created by yz on 21/1/2022
  */
object Cp {

  case class Props(
      fsData: FsData,
      fsDataModifyF: (FsData=>FsData) => SyncIO[Unit],
      showIdStr: String,
      extraData: ExtraData
  ){
    @inline def render: VdomElement = {
      Component(this)
    }
  }

  val Component = ScalaFnComponent[Props] { props =>
    object FTool {

      def dataMatrixModifyF = (dataMatrixData: DataMatrixData=>DataMatrixData) => {
        val modifyF =modifyLens[FsData](_.dataMatrix).using(dataMatrixData)
        props.fsDataModifyF(modifyF)
      }

    }

    val displayStr =
      if (props.showIdStr == props.fsData.dataMatrix.nodeId) "block" else "none"

    div(
      className := "myArg",
      display := displayStr,
      DataMatrixCp.Props(
        dataMatrix = props.fsData.dataMatrix,
        dataMatrixModifyF = FTool.dataMatrixModifyF,
        extraData = props.extraData
      ).render
    )

  }

}
